<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title><{$tit}></title>
<link rel="stylesheet" href="<{$ipath}>ucenter/style/ucenter.css">
<script src="<{$ipath}>public/js/jquery.js"></script>
<script type="text/javascript"  src="<{$ipath}>wx/js/ajaxfileupload.js"></script>
</head>
<body>
<div class="servicebox">
    <div class="content01">
       <ul class="title"><{$tit}></ul>
      <ul class="pcnav">
      <a href="?g=ucenter&m=ucenter&a=user"><li <{$navstyle.user}>>用户列表</li></a>
      <a href="?g=ucenter&m=ucenter&a=settool"><li <{$navstyle.tool}>>功能设置</li></a>
      </ul>
    <div class="setinfo">
    <form action="?g=ucenter&m=ucenter&a=settool" method="post" target="hiddfrm" />
        <ul class="settit">功能设置:</ul>
        <ul class="setput" data-maxnum="<{$maxnum}>">
        	<li>平台功能：<{section name=l loop=$list}><input name="uset[]" type="checkbox" value="<{$list[l].id}>" <{if !empty($setarr) && in_array($list[l].id,$setarr)}>checked<{/if}> /><{$list[l].title}><{/section}></li>
            <li>自定义功能：<em><a class="button" onClick="addtool()">添加功能</a></em></li>
            <{section name=l loop=$ulist}>
            	<li>名称：<input type="text" class="put" name="title[<{$smarty.section.l.iteration}>]" value="<{$ulist[l].title}>" /> 地址：<input type="text" class="put" name="url[<{$smarty.section.l.iteration}>]" value="<{$ulist[l].url}>" />
                 图标：<span class="span<{$smarty.section.l.iteration}>"><img src="<{$ulist[l].icon}>" height="50" width="50" /><input type="hidden" name="icon[<{$smarty.section.l.iteration}>]" value="<{$ulist[l].icon}>" /></span><a class="button1 divre">更换图标<input id="img<{$smarty.section.l.iteration}>" type="file" onChange="uploadpic(<{$smarty.section.l.iteration}>)" class="upfile" name="img" /></a> 状态:<{if in_array($ulist[l].id,$setarr)}><a class="cancel1" href="?g=ucenter&m=ucenter&a=cstatus&status=0&id=<{$ulist[l].id}>" onClick="isage()" target="hiddfrm">已启用</a><{else}><a class="button1"  href="?g=ucenter&m=ucenter&a=cstatus&status=1&id=<{$ulist[l].id}>" target="hiddfrm" onClick="return isage()">未启用</a><{/if}>
                 <input type="hidden" name="id[<{$smarty.section.l.iteration}>]" value="<{$ulist[l].id}>" /></li>
            <{/section}>
        </ul>
        <ul id="subbtn"><{if empty($maxnum)}><a class="cancel">提交</a><{else}><input type="submit" class="button" value="提交"><{/if}></ul>
     </form>
    </div>
	</div>
</div>
<script>
function addtool(){
	var num = parseInt($(".setput").attr("data-maxnum")) + 1;
	$(".setput").append('<li>名称：<input type="text" class="put" name="title['+num+']" /> 地址：<input type="text" class="put" name="url['+num+']" /> 图标：<span class="span'+num+'"></span><a class="button1 divre">+图标<input type="file" id="img'+num+'" onChange="uploadpic('+num+')" class="upfile" name="img" /></a></li>');
	$(".setput").attr("data-maxnum",num);
	if($("#subbtn").html()=='<a class="cancel">提交</a>'){
		$("#subbtn").html('<input type="submit" class="button" value="提交">');
	}
}
function uploadpic(n){
	var url='?g=ucenter&m=ucenter&a=uploadpic';
	$.ajaxFileUpload({
			url:url,
			dataType:'json',
			fileElementId:'img'+n,
			type:'post',
			secureuri:false,
			success:function(data){
				$('.loading').hide();
				if(data.error==1000 || data.error=='1000'){
					alert('上传成功'); 
					$(".span"+n).html('<img src="'+data.pic+'" height="50" width="50" /><input type="hidden" name="icon['+n+']" value="'+data.pic+'" />');
				}else{
					alert(data.errmsg);
					return false;
				}
			},
		});
}
function isage(){
	if(confirm('请确认操作')){
		return true;
	}else{
		return false;
	}
}
</script>
<iframe width="0" height="0" name="hiddfrm" id="hiddfrm" frameborder="0" scrolling="no" style="display:none"></iframe>
</body>
</html>
